<?php

use App\Enums\UserStatus;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('admin_user_id')->default(0)->index()->comment('后台账号id');
            $table->unsignedBigInteger('ding_id')->default(0)->index()->comment('应用id');
            $table->string('dept_id')->default('')->index()->comment('部门id');
            $table->string('name')->default('')->comment('昵称');
            $table->string('phone')->default('')->comment('手机');
            $table->string('avatar')->default('')->comment('头像');
            $table->string('userid')->default('')->comment('钉钉id');
            $table->tinyInteger('status')->default(UserStatus::WORKING)->comment('状态:0=离职,1=在职');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
